package com.whpost.api.config;

import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Peter Cheung
 * 暂时不知道作用
 * 2023/7/19 13:52
 */
@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {
    // 注册 Sa-Token 拦截器，打开注解式鉴权功能
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册 Sa-Token 的路由拦截器
        registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
                .addPathPatterns("/**")
                .excludePathPatterns("/qyh/auth/login")
                .excludePathPatterns("/qyh/auth/login_sjh")
                .excludePathPatterns("/qyh/auth/buildOauth2Url")
                .excludePathPatterns("/qyh/auth/test")
                .excludePathPatterns("/qyh/qfkb/jgkb_xls")
                .excludePathPatterns("/qyh/qfkb/yqkb_xls")
                .excludePathPatterns("/qyh/qfkb/xls/**")
                .excludePathPatterns("/xgmm")
                .excludePathPatterns("/vcode");
    }

}